import {getBannerAPI, getBaseCategoryListAPI, getFloorAPI} from "@/api/homeApi";

const actions = {
    /* 发送请求获取三级分类的actions */
    async fetchCategoryList(context) {
        const {data: categoryList} = await getBaseCategoryListAPI()
        context.commit("updateCategoryList", categoryList)
    },

    /* 发送请求获取轮播图的actions */
    async fetchBannerList(context) {
        const {result: bannerList} = await getBannerAPI()
        context.commit("updateBannerList", bannerList)
    },
    /* 发送请求获取floor楼层actions */
    async fetchFloorList(context) {
        const {data: result} = await getFloorAPI()
        context.commit("updateFloorList", result.data)
    }
}
const mutations = {
    /* 更新三级分类的mutations */
    updateCategoryList(state, categoryList) {
        state.categoryList = categoryList
    },
    /* 更新轮播图的mutations */
    updateBannerList(state, bannerList) {
        state.bannerList = bannerList
    },
    /* 更新楼层的mutations */
    updateFloorList(state, floorList) {
        state.floorList = floorList
    }
}
const state = () => {
    return {
        categoryList: [],
        bannerList: [],
        floorList: [],
        navsList: ["服装城", "美妆馆", "尚品汇超市", "全球购", "闪购", "团购", "有趣", "秒杀"],
    }
}
const getters = {}
export default {
    actions,
    mutations,
    state,
    getters,
    namespaced: true
}
